package com.cskaoyan.service.wx.impl;

import com.cskaoyan.bean.bo.WxFeedbackBo;
import com.cskaoyan.bean.po.MarketFeedback;
import com.cskaoyan.bean.po.MarketUser;
import com.cskaoyan.mapper.MarketFeedbackMapper;
import com.cskaoyan.service.wx.WxFeedbackService;
import com.cskaoyan.util.GetInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author jzp
 * @since 2022/11/23 10:27
 */
@Service
public class WxFeedbackServiceImpl implements WxFeedbackService {
    @Autowired
    MarketFeedbackMapper marketFeedbackMapper;

    @Override
    @Transactional
    public Integer submit(WxFeedbackBo wxFeedbackBo) {
        MarketUser wxLoginInfo = GetInfo.getWxLoginInfo();
        MarketFeedback marketFeedback = new MarketFeedback();
        marketFeedback.setMobile(wxFeedbackBo.getMobile());
        marketFeedback.setFeedType(wxFeedbackBo.getFeedType());
        marketFeedback.setContent(wxFeedbackBo.getContent());
        marketFeedback.setHasPicture(wxFeedbackBo.getHasPicture());
        marketFeedback.setPicUrls(wxFeedbackBo.getPicUrls());

        Date date = new Date();
        marketFeedback.setAddTime(date);
        marketFeedback.setUserId(wxLoginInfo.getId());
        marketFeedback.setUsername(wxLoginInfo.getUsername());

        int num = marketFeedbackMapper.insertSelective(marketFeedback);
        return num;
    }
}
